package cn.tedu.csmall520.stock.webapi.quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class StockQuartzConfig {

    @Bean
    public JobDetail addStockCount(){
        return JobBuilder.newJob()
                .withIdentity("addStockCount")
                .storeDurably()
                .build();
    }

    @Bean
    public Trigger showTimeTrigger(){
        CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule("0 0/2 * * * ?");
        return TriggerBuilder.newTrigger()
                .forJob(addStockCount())
                .withIdentity("showTimeTrigger")
                .withSchedule(cron)
                .build();
    }
}
